package com.komeri.komeriapl;

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 2014/10/10
 * adapter of navication list
 * @author Ma MengHong
 *
 */
public class TextAdapter extends BaseAdapter{
	
	public Context context;
	private List<String> infoList;
	public final String Tag ="HistoryAdapter";
	public TextAdapter adapter;
	
	
	
	public TextAdapter(Context ct,List<String> list){
		this.context = ct;
		this.infoList = list;
		
		adapter = this;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return infoList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return infoList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder = null;
		  
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.adapter_text, null);
            viewHolder.name = (TextView) convertView.findViewById(R.id.adapter_text_name); 
            viewHolder.line = (View) convertView.findViewById(R.id.adapter_text_line); 
            
            convertView.setTag(viewHolder);
        } else {
        	
            viewHolder = (ViewHolder) convertView.getTag();
        }
        
       
        viewHolder.name.setText(infoList.get(position));
        
        if(position == (infoList.size()-1)){
        	viewHolder.line.setVisibility(View.GONE);
        }else{
        	viewHolder.line.setVisibility(View.VISIBLE);
        }

        
		return convertView;
	}
	public final static class ViewHolder {
        TextView name;
        View line;
        
        
    }
	

	
	
	

}